<template>
  <el-container>
    <el-header><DepartmentSearch @inputEvent="onSearch" ref="searchDom"></DepartmentSearch></el-header>
    <el-main class="doctor-main">
      <DepartmentCard v-for="item in searchList" :depInfo="item" :key="item.id"></DepartmentCard>
    </el-main>
  </el-container>
</template>

<script>
import DepartmentSearch from "../../components/admin/DepartmentSearch";
import DepartmentCard from "../../components/admin/DepartmentCard";
import DoctorCard from "../../components/admin/DoctorCard";
export default {
  name: "AdminDepartment",
  components: {DepartmentCard, DepartmentSearch},
  data() {
    return {
      inputName: '',
      inputDepartment:'',
      searchValue: ''
    }
  },
  methods:{
    onSearch(event){
      console.log(event)
      this.searchValue = event
    },
  },
  computed:{
    depInfo(){
      const data = this.$store.state.adminModules.departmentList
      return data.map(item => {
        return {
          id: item.id,
          depName: item.name,
          synopsis: item.synopsis,
        }
      })
    },
    searchList(){
      if (this.searchValue === '')  return this.depInfo
      return this.depInfo.filter(item => JSON.stringify(item).indexOf(this.searchValue) !== -1)
    }
  },
  async mounted() {
    // console.log(this.$store.state.adminModules)
    await this.$store.dispatch("getDepartmentList")
  }
  // data() {
  //   return {
  //     inputDepartment:'',
  //     depData: [{
  //       depId: '1',
  //       depName: '耳鼻喉科',
  //       depMember: '9',
  //       depCreate: '2007-9-8',
  //       depPhoto: 'https://cdn.pixabay.com/photo/2016/06/05/14/11/dentist-1437413__340.jpg' ,
  //         },
  //       {
  //         depId: '2',
  //         depName: '检验室',
  //         depMember: '25',
  //         depCreate: '2007-9-8',
  //         depPhoto: 'https://cdn.pixabay.com/photo/2021/10/05/15/23/dentistry-6682984__340.jpg'
  //       },
  //       {
  //         depId: '3',
  //         depName: '影像科',
  //         depMember: '25',
  //         depCreate: '2007-9-8',
  //         depPhoto: 'https://tse2-mm.cn.bing.net/th/id/OIP-C.d2u2aILme5TZgNMJQR0JBAHaE7?w=234&h=180&c=7&r=0&o=5&dpr=1.38&pid=1.7',
  //       },
  //       {
  //         depId: '4',
  //         depName: '内科',
  //         depMember: '25',
  //         depCreate: '2007-9-8',
  //         depPhoto: 'https://cdn.pixabay.com/photo/2020/11/03/15/32/doctor-5710159__340.jpg',
  //       },
  //
  //
  //     ],
  //   }
  // },
}
</script>
